package cn.amossun.starter.event.property;

import cn.amossun.starter.event.enums.DurabilityEnum;
import cn.amossun.starter.event.enums.ExchangeTypeEnum;
import lombok.Data;
import org.springframework.amqp.core.Exchange;

import java.util.Map;

@Data
public class EventExchangeContext {

    private final String exchangeName;

    private final ExchangeTypeEnum type;

    private final DurabilityEnum durability;

    private final boolean autoDelete;

    private final boolean internal;

    private final Map<String, Object> argumentsMap;

    private Exchange exchange;

    public EventExchangeContext(String exchangeName, ExchangeTypeEnum type, DurabilityEnum durability, boolean autoDelete) {
        this(exchangeName, type, durability, autoDelete, false, null);
    }

    public EventExchangeContext(String exchangeName,
                                ExchangeTypeEnum type,
                                DurabilityEnum durability,
                                boolean autoDelete,
                                boolean internal,
                                Map<String, Object> argumentsMap) {
        this.exchangeName = exchangeName;
        this.type = type;
        this.durability = durability;
        this.autoDelete = autoDelete;
        this.internal = internal;
        this.argumentsMap = argumentsMap;
    }

    public boolean isDurable(){
        if(durability == null){
            return false;
        }
        return durability == DurabilityEnum.DURABLE ? true : false;
    }

}
